package com.fortune.controller;

import java.util.List;

import com.fortune.base.BaseController;
import com.fortune.dto.excution.DriverUploadExcution;
import com.fortune.enums.DriverUploadEnum;
import com.fortune.service.DriverUploadService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fortune.base.BaseAPIExcution;
import com.fortune.vo.driverUpload.UploadInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "wechat/driverUpload", description = "装货清单", tags = {"微信小程序（司机）：装货清单"})
@RestController
@RequestMapping("wechat/driverUpload")
public class DriverUploadController extends BaseController{
	@Autowired
	private DriverUploadService driverUploadService;

	@ApiOperation(value = "装货清单", nickname = "driverUploadList", notes = "", tags = {"@郭阳"})
	@ApiImplicitParams({
		@ApiImplicitParam(name="Authorization", value="登录返回的token值",paramType="header",dataType="String",required = true)
	})
    @GetMapping(value = "list",
        produces = { MediaType.APPLICATION_JSON_VALUE })
	public BaseAPIExcution<List<UploadInfo>> list() {
		String did = getDId();
		String deliveryUser = getUserId();
		List<UploadInfo> findListUploadInfo = driverUploadService.findListUploadInfo(did, deliveryUser);
		if(findListUploadInfo.size() == 0){
			return new DriverUploadExcution<List<UploadInfo>>(findListUploadInfo, DriverUploadEnum.FIND_RESULT_AIR);
		}

		return new DriverUploadExcution<List<UploadInfo>>(findListUploadInfo, DriverUploadEnum.FIND_SUCCESS);
	}
}
